﻿using DGIS.GscloudService.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;

namespace DGIS.Control.系统管理
{
    public class SysControl
    {
        /// <summary>
        /// 检查更新
        /// </summary>
        /// <returns></returns>
        public string CheckSysUpdate()
        {
            string updateUrl = "";

            string url = "https://gitee.com/JFly/dgis.-rs/releases/release";
            HttpService httpService = new HttpService();
            CookieContainer cookieContainer = new CookieContainer();
            string resultStr= httpService.GetHttpWebGetReuslt(url,ref cookieContainer);
            if (!string.IsNullOrEmpty(resultStr))
            {
                string a = "<a target=\"_blank\" class=\"title\" href=\"/JFly/dgis.-rs/releases/release\">";
                int sIndex = resultStr.IndexOf(a)+a.Length;
                
                if (sIndex != -1 )
                {
                    resultStr = resultStr.Substring(sIndex);
                    int length = resultStr.IndexOf("</a>");

                    updateUrl = resultStr.Substring(0, length).Trim();
                }
            }

            return updateUrl;
        }
    }
}
